package main

import (
	"fmt"
	"micro-bbs/configs"
	"micro-bbs/cron"
	"micro-bbs/etcd"
	"micro-bbs/initialize"
	"micro-bbs/routers"
	"micro-bbs/websocket"
)

func main() {
	//获得配置对象
	Yaml := configs.InitConfig()
	initialize.Init(Yaml)

	//注册nacos
	//go func() {
	//	initialize.InitRegisterServer()
	//}()

	//处理定时任务
	//go cron.InitCron()

	//开启三个线程处理MQ消费者数据
	for i := 0; i < 3; i++ {
		go cron.InitConsumer(i)
	}

	//注册到etcd服务
	go etcd.Regmain()

	//websocke服务
	//go websocket.WebSocket()
	go websocket.Run()

	// 初始化路由
	r := routers.SetupRouter()

	err := r.Run(":8081")
	if  err != nil {
		fmt.Println("startup service failed, err:%v\n", err)
	}
}